﻿Imports System.Data.OleDb
Public Class Albums
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        pnlTempest.Visible = False
        pnlBoss.Visible = False
        pnlChevelleSS.Visible = False
        pnlCOPO.Visible = False
        pnlCorvette.Visible = False
        pnlGSX.Visible = False
        pnlPlymouth.Visible = False
        pnlShelby.Visible = False
        pnlCamaroZ28.Visible = False
        pnlCamaroZL1.Visible = False
    End Sub

    Protected Sub lvCarNames_SelectedIndexChanging(ByVal sender As Object, ByVal e As ListViewSelectEventArgs) Handles lvCarNames.SelectedIndexChanging

        lvCarNames.SelectedIndex = e.NewSelectedIndex
        Dim cID = lvCarNames.SelectedDataKey.Value.ToString
        If cID = 1 Then
            pnlBoss.Visible = True
            'Session("cID") = 1
            'Dim SCid = Session("cID").ToString()
            'Bind1(SCid)
        ElseIf cID = 2 Then
            pnlChevelleSS.Visible = True
        ElseIf cID = 3 Then
            pnlCOPO.Visible = True
        ElseIf cID = 4 Then
            pnlCorvette.Visible = True
        ElseIf cID = 5 Then
            pnlGSX.Visible = True
        ElseIf cID = 6 Then
            pnlPlymouth.Visible = True
        ElseIf cID = 7 Then
            pnlShelby.Visible = True
        ElseIf cID = 8 Then
            pnlTempest.Visible = True
        ElseIf cID = 9 Then
            pnlCamaroZ28.Visible = True
        ElseIf cID = 10 Then
            pnlCamaroZL1.Visible = True

        End If

    End Sub

    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim conn As OleDbConnection = New OleDbConnection(ConfigurationManager.ConnectionStrings("carsconn").ConnectionString)
        Dim sql = "INSERT INTO Cars_UserUploads (Uploader_UName,Img_Loc,CC_ID,C_Desc) VALUES (@f1,@f2,@f3,@f4)"
        Dim cmd = New OleDbCommand(sql, conn)
        If (imgCar.HasFile) Then
            imgCar.SaveAs(Request.MapPath("Images/XL") & "/" & ddlCars.SelectedItem.Text & "/" & imgCar.FileName)
        End If
        conn.Open()
        cmd.Parameters.AddWithValue("@f1", User.Identity.Name)

        cmd.Parameters.AddWithValue("@f2", "Images/XL/" & ddlCars.SelectedItem.Text & "/" & imgCar.FileName)
        cmd.Parameters.AddWithValue("@f3", ddlCars.SelectedValue)
        cmd.Parameters.AddWithValue("@f4", txtDes.Text)
        cmd.ExecuteNonQuery()
        Dim cID = ddlCars.SelectedValue.ToString()
        conn.Close()
        Response.Redirect(Request.Url.AbsoluteUri)

    End Sub



End Class